home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / text / tex / tgrind.lha / TGrind / retest.c < prev    next >
C/C++ Source or Header  |  1993-01-04  |  1KB  |  68 lines

  1. #ifndef lint
  2. static char *sccsid="@(#)retest.c    1.1 (LBL) 3/29/85";
  3. #endif
  4. static char sccsid[] = "@(#)retest.c    4.1    (Berkeley)    10/19/82";
  5.  
  6. #include <ctype.h>
  7.  
  8. int l_onecase = 0;
  9. char * _start;
  10. char * _escaped;
  11. char * convexp();
  12. char * expmatch();
  13. main()
  14. {
  15.     char reg[132];
  16.     char *ireg;
  17.     char str[132];
  18.     char *match;
  19.     char matstr[132];
  20.     char c;
  21.  
  22.     while (1) {
  23.     printf ("\nexpr: ");
  24.     scanf ("%s", reg);
  25.     ireg = convexp(reg);
  26.     match = ireg;
  27.     while(*match) {
  28.         switch (*match) {
  29.  
  30.         case '\\':
  31.         case '(':
  32.         case ')':
  33.         case '|':
  34.         printf ("%c", *match);
  35.         break;
  36.  
  37.         default:
  38.         if (isalnum(*match))
  39.             printf("%c", *match);
  40.         else
  41.             printf ("<%03o>", *match);
  42.         break;
  43.         }
  44.         match++;
  45.     }
  46.     printf("\n");
  47.     getchar();
  48.     while(1) {
  49.         printf ("string: ");
  50.         match = str;
  51.         while ((c = getchar()) != '\n')
  52.         *match++ = c;
  53.         *match = 0;
  54.         if (str[0] == '#')
  55.         break;
  56.         matstr[0] = 0;
  57.         _start = str;
  58.         _escaped = 0;
  59.         match = expmatch (str, ireg, matstr);
  60.         if (match == 0)
  61.         printf ("FAILED\n");
  62.         else
  63.         printf ("match\nmatstr = %s\n", matstr);
  64.     }
  65.  
  66.     }
  67. }
  68.